package com.hualan.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.entity.Cspi;
import com.hualan.sfzy.mapper.CspiMapper;
import com.hualan.sfzy.service.CspiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class CspiServiceImpl implements CspiService {

    @Autowired
    private CspiMapper cspiMapper;

    @Override
    public int add(Cspi entity) {
        return 0;
    }

    @Override
    public int addSelective(Cspi entity) {
        return cspiMapper.insert(entity);
    }

    @Override
    public int edit(Cspi entity) {
        return cspiMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return cspiMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return cspiMapper.deleteBatch(ids);
    }

    @Override
    public List<Cspi> find() {
        return Collections.emptyList();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, Cspi entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<Cspi> list = cspiMapper.selectCspiAndCounselor(entity);
        PageInfo<Cspi> pageInfo = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put("pageInfo", pageInfo);
        return map;
    }

    @Override
    public Cspi findById(Integer id) {
        return cspiMapper.selectById(id);
    }

    public List<Cspi> findCspiAndCounselorAll(){
        List<Cspi> list = cspiMapper.selectCspiAndCounselorAll();
        return list;
    }




}
